public class Test {

    public static void main(String[] args) {
        LinkedList2 linkedList2 = new LinkedList2();
        linkedList2.addLast(12);
        linkedList2.addLast(23);
        linkedList2.addLast(23);
        linkedList2.addLast(12);
        boolean flg = linkedList2.chkPalindrome();
        System.out.println(flg);

        LinkedList2 linkedList3 = new LinkedList2();
        linkedList3.addLast(12);
        linkedList3.addLast(23);
        linkedList3.addLast(34);
        linkedList3.addLast(23);
        linkedList3.addLast(12);
        linkedList3.display();
        boolean flg2 = linkedList3.chkPalindrome();
        System.out.println(flg2);

    }

    //合并两个有序链表
    public  static LinkedList2.ListNode mergeTwoLists(LinkedList2.ListNode headA,
                                                      LinkedList2.ListNode headB) {

        LinkedList2.ListNode newH = new LinkedList2.ListNode(-1);
        LinkedList2.ListNode tmp = newH;

        while(headA != null && headB != null) {
            if(headA.val < headB.val) {
                tmp.next = headA;
                tmp = headA;
                headA = headA.next;
            }else {
                tmp.next = headB;
                tmp = headB;
                headB = headB.next;
            }
        }
        if(headA != null) {
            tmp.next = headA;
        }
        if(headB != null) {
            tmp.next = headB;
        }
        return newH.next;
    }
    public static void main1(String[] args) {
        LinkedList2 linkedList2 = new LinkedList2();
        linkedList2.addLast(1);
        linkedList2.addLast(2);
        linkedList2.addLast(3);
        linkedList2.addLast(4);
        linkedList2.addLast(5);
        linkedList2.display();
        linkedList2.reverseList();
        linkedList2.display();
        LinkedList2.ListNode ret = linkedList2.middleNode();
        System.out.println(ret.val);
        int ret2 = linkedList2.kthToLast(2);
        System.out.println(ret2);

        LinkedList2 linkedList1 = new LinkedList2();

        linkedList1.addLast(11);
        linkedList1.addLast(21);
        linkedList1.addLast(31);
        linkedList1.addLast(41);
        linkedList1.addLast(51);
        linkedList1.addLast(61);
        linkedList1.display();

        System.out.println("=====");
        LinkedList2 linkedList12 = new LinkedList2();

        linkedList12.addLast(10);
        linkedList12.addLast(20);
        linkedList12.addLast(30);
        linkedList12.addLast(40);
        linkedList12.addLast(50);
        linkedList12.addLast(60);
        linkedList12.display();

        System.out.println("=====");

        LinkedList2.ListNode newHead = mergeTwoLists(linkedList1.head,linkedList12.head);

        linkedList1.display(newHead);
    }
}
